// 引入路由
// import Home from '@/pages/Home'
// import Login from '@/pages/Login'
// import Register from '@/pages/Register'
// import Search from '@/pages/Search'
// import Detail from '@/pages/Detail'
// import AddCartSuccess from '@/pages/AddCartSuccess'
// import ShopCart from '@/pages/ShopCart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
// import Center from '@/pages/Center'

// 引入二级路由
// import MyOrder from "@/pages/Center/myOrder";
// import GroupOrder from "@/pages/Center/groupOrder";


export default [
    {
        path: '/home',
        // 路由懒加载 当路由被访问时才加载对应的组件 更加高效
        component: () => import('@/pages/Home'),
        meta: { show: true }
    },
    {
        path: '/login',
        // 路由懒加载
        component: () => import('@/pages/Login'),
        meta: { show: false }
    },
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: { show: false }
    },
    {
        name: 'search',
        // 设置路由路径并接受参数
        path: '/search/:keyword?',
        component: () => import('@/pages/Search'),
        meta: { show: true }
    },
    {
        // 设置路由路径并接受参数
        path: '/detail/:skuid',
        component: () => import('@/pages/Detail'),
        meta: { show: true }

    },
    {
        path: '/addcartsuccess',
        name: 'addcartsuccess',
        component: () => import('@/pages/AddCartSuccess'),
        meta: { show: true }

    },
    {
        path: '/shopcart',
        component: () => import('@/pages/ShopCart'),
        meta: { show: true }

    },
    {
        //交易页面
        path: '/trade',
        component: () => import('@/pages/Trade'),
        meta: { show: true },
        // 使用独享路由守卫
        beforeEnter: (to, from, next) => {
            // 只有从购物车跳转过来才能进入
            if (from.path == '/shopcart') {
                next();
            } else {
                // 中断路由跳转
                next(false)
            }
        }
    },
    {
        path: '/pay',
        component: () => import('@/pages/Pay'),
        meta: { show: true },
        // 使用独享路由守卫
        beforeEnter: (to, from, next) => {
            // 只有从交易页面跳转过来才能进入
            if (from.path == '/trade') {
                next();
            } else {
                // 中断路由跳转
                next(false)
            }
        }

    },
    {
        path: '/paysuccess',
        component: () => import('@/pages/PaySuccess'),
        meta: { show: true }

    },
    {
        path: '/center',
        component: () => import('@/pages/Center'),
        meta: { show: true },
        // 二级路由
        children: [
            {
                // 二级路由路径的斜杠要么不写要么写全
                path: 'myorder',
                component: () => import("@/pages/Center/myOrder"),
            },
            {
                path: 'grouporder',
                component: () => import("@/pages/Center/groupOrder"),
            },
            // 进入/center页面 默认显示/center/myorder页面
            {
                path: "/center",
                redirect: '/center/myorder'
            }
        ]

    },

    // 访问项目时 直接跳转到home组件
    {
        path: '*',
        redirect: '/home'
    }
]